package com.whcoding.test.common;


import com.whcoding.test.constant.BaseConstant;
import com.whcoding.test.constant.DateStyle;
import com.whcoding.test.constant.WeekEnum;
import org.apache.commons.lang3.StringUtils;

import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.*;

public class DateTimeUtils {
	private static final ThreadLocal<SimpleDateFormat> threadLocal = new ThreadLocal();
	private static final Object object = new Object();
	private static Date originalDate = null;

	public DateTimeUtils() {
	}


	public static Date parseDateByString(String dateStr, DateStyle dateStyle) throws ParseException {
		SimpleDateFormat sdf = new SimpleDateFormat(dateStyle.getValue());
		return sdf.parse(dateStr);
	}

	/**
	 * 将string 转化为Date
	 * yyyy-MM-dd HH:mm:ss
	 *
	 * @param dateStr
	 * @return
	 * @throws ParseException
	 */
	public static Date parseDateByString(String dateStr, String dateStyleStr) throws ParseException {
		SimpleDateFormat sdf = new SimpleDateFormat(dateStyleStr);
		return sdf.parse(dateStr);
	}

	/**
	 * 将string 转化为Date
	 *
	 * @param dateStr
	 * @return
	 * @throws ParseException
	 */
	public static Date parseDateByString(String dateStr) {
		try {
			SimpleDateFormat sdf = new SimpleDateFormat(DateStyle.YYYY_MM_DD_HH_MM_SS.getValue());
			return sdf.parse(dateStr);
		} catch (Exception ex) {
			ex.getMessage();
		}
		return null;
	}


	/**
	 * 将string 累行转化为Date
	 *
	 * @param dateStr
	 * @return
	 * @throws ParseException
	 */
	public static Date parseDateString(String dateStr) throws ParseException {

		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

		return sdf.parse(dateStr);
	}

	/**
	 * 将Date类型转化为String类型
	 *
	 * @param date
	 * @return
	 */
	public static String DateToStrign(Date date) {

		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		return sdf.format(date);
	}

	/**
	 * 获取毫秒
	 *
	 * @return
	 */
	public static String getDateByMillisecondStr() {
		String aa = DateTimeUtils.DateToString(new Date(), DateStyle.YYYY_MM_DD_HH_MM_SS_SSS);
		return aa;
	}


	/**
	 * 获取初始时间
	 *
	 * @return 返回默认时间1990-01-01
	 */
	public static Date getOriginalDate() {
		return new Date(StringToDate("1990-01-01").getTime());
	}


	public static Date getOriginalDate(String date) {
		if (originalDate == null) {
			DateStyle dateStyle = getDateStyle(date);
			originalDate = StringToDate(date, dateStyle);
		}
		return originalDate;
	}


	private static SimpleDateFormat getDateFormat(String pattern) throws RuntimeException {
		SimpleDateFormat dateFormat = threadLocal.get();
		if (dateFormat == null) {
			Object var2 = object;
			synchronized (object) {
				if (dateFormat == null) {
					dateFormat = new SimpleDateFormat(pattern);
					dateFormat.setLenient(false);
					threadLocal.set(dateFormat);
				}
			}
		}

		dateFormat.applyPattern(pattern);
		return dateFormat;
	}

	private static int getInteger(Date date, int dateType) {
		int num = 0;
		Calendar calendar = Calendar.getInstance();
		if (date != null) {
			calendar.setTime(date);
			num = calendar.get(dateType);
		}

		return num;
	}

	/**
	 * 时间加几天
	 *
	 * @param date     时间
	 * @param dateType 时间类型
	 * @param amount
	 * @return
	 */
	private static String addInteger(String date, int dateType, int amount) {
		String dateString = null;
		DateStyle dateStyle = getDateStyle(date);
		if (dateStyle != null) {
			Date myDate = StringToDate(date, dateStyle);
			myDate = addInteger(myDate, dateType, amount);
			dateString = DateToString(myDate, dateStyle);
		}

		return dateString;
	}


	private static Date addInteger(Date date, int dateType, int amount) {
		Date myDate = null;
		if (date != null) {
			Calendar calendar = Calendar.getInstance();
			calendar.setTime(date);
			calendar.add(dateType, amount);
			myDate = calendar.getTime();
		}

		return myDate;
	}

	/**
	 * 获取准确的时间
	 *
	 * @param timestamps 时间差
	 * @return
	 */
	private static Date getAccurateDate(List<Long> timestamps) {
		Date date = null;
		long timestamp = 0L;
		Map<Long, long[]> map = new HashMap();
		List<Long> absoluteValues = new ArrayList();
		if (timestamps != null && timestamps.size() > 0) {
			if (timestamps.size() > 1) {
				for (int i = 0; i < timestamps.size(); ++i) {
					for (int j = i + 1; j < timestamps.size(); ++j) {
						long absoluteValue = Math.abs(timestamps.get(i).longValue() - timestamps.get(j).longValue());
						absoluteValues.add(Long.valueOf(absoluteValue));
						long[] timestampTmp = new long[]{timestamps.get(i).longValue(), timestamps.get(j).longValue()};
						map.put(Long.valueOf(absoluteValue), timestampTmp);
					}
				}

				long minAbsoluteValue = -1L;
				if (!absoluteValues.isEmpty()) {
					minAbsoluteValue = absoluteValues.get(0).longValue();

					for (int i = 1; i < absoluteValues.size(); ++i) {
						if (minAbsoluteValue > absoluteValues.get(i).longValue()) {
							minAbsoluteValue = absoluteValues.get(i).longValue();
						}
					}
				}

				if (minAbsoluteValue != -1L) {
					long[] timestampsLastTmp = map.get(Long.valueOf(minAbsoluteValue));
					long dateOne = timestampsLastTmp[0];
					long dateTwo = timestampsLastTmp[1];
					if (absoluteValues.size() > 1) {
						timestamp = Math.abs(dateOne) > Math.abs(dateTwo) ? dateOne : dateTwo;
					}
				}
			} else {
				timestamp = timestamps.get(0).longValue();
			}
		}

		if (timestamp != 0L) {
			date = new Date(timestamp);
		}

		return date;
	}

	/**
	 * 判断是否为时间类型
	 *
	 * @param date
	 * @return
	 */
	public static boolean isDate(String date) {
		boolean isDate = false;
		if (date != null && getDateStyle(date) != null) {
			isDate = true;
		}

		return isDate;
	}

	/**
	 * 根据时间获取时间类型
	 *
	 * @param date
	 * @return
	 */
	public static DateStyle getDateStyle(String date) {
		DateStyle dateStyle = null;
		Map<Long, DateStyle> map = new HashMap();
		List<Long> timestamps = new ArrayList();
		DateStyle[] var4 = DateStyle.values();
		int var5 = var4.length;

		for (int var6 = 0; var6 < var5; ++var6) {
			DateStyle style = var4[var6];
			if (!style.isShowOnly()) {
				Date dateTmp = null;
				if (date != null) {
					try {
						ParsePosition pos = new ParsePosition(0);
						dateTmp = getDateFormat(style.getValue()).parse(date, pos);
						if (pos.getIndex() != date.length()) {
							dateTmp = null;
						}
					} catch (Exception var10) {
					}
				}

				if (dateTmp != null) {
					timestamps.add(Long.valueOf(dateTmp.getTime()));
					map.put(Long.valueOf(dateTmp.getTime()), style);
				}
			}
		}

		Date accurateDate = getAccurateDate(timestamps);
		if (accurateDate != null) {
			dateStyle = map.get(Long.valueOf(accurateDate.getTime()));
		}

		return dateStyle;
	}


	/**
	 * 将string类型转化为Date类型
	 *
	 * @param date
	 * @return
	 */
	public static Date StringToDate(String date) {
		DateStyle dateStyle = getDateStyle(date);
		return StringToDate(date, dateStyle);
	}

	/**
	 * 将string 类型转化为时间类型 以及格式的转化
	 *
	 * @param date
	 * @param pattern
	 * @return
	 */
	public static Date StringToDate(String date, String pattern) {
		Date myDate = null;
		if (date != null) {
			try {
				myDate = getDateFormat(pattern).parse(date);
			} catch (Exception var4) {
			}
		}

		return myDate;
	}

	/**
	 * string 类型转化为时间类型
	 *
	 * @param date      字符串时间
	 * @param dateStyle 时间类型
	 * @return
	 */
	public static Date StringToDate(String date, DateStyle dateStyle) {
		Date myDate = null;
		if (dateStyle != null) {
			myDate = StringToDate(date, dateStyle.getValue());
		}

		return myDate;
	}

	/**
	 * 将Date 转化为string 类型
	 *
	 * @param date    日期
	 * @param pattern 格式；类型
	 * @return
	 */
	public static String DateToString(Date date, String pattern) {
		String dateString = null;
		if (date != null) {
			try {
				dateString = getDateFormat(pattern).format(date);
			} catch (Exception var4) {
			}
		}

		return dateString;
	}

	/**
	 * 将Data类型转化为string类型
	 *
	 * @param date
	 * @param dateStyle
	 * @return
	 */
	public static String DateToString(Date date, DateStyle dateStyle) {
		String dateString = null;
		if (dateStyle != null) {
			dateString = DateToString(date, dateStyle.getValue());
		}

		return dateString;
	}

	/**
	 * 将string类型进行转化
	 *
	 * @param date
	 * @param newPattern
	 * @return
	 */
	public static String StringToString(String date, String newPattern) {
		DateStyle oldDateStyle = getDateStyle(date);
		return StringToString(date, oldDateStyle, newPattern);
	}

	/**
	 * 时间类型进行转化
	 *
	 * @param date
	 * @param newDateStyle
	 * @return
	 */
	public static String StringToString(String date, DateStyle newDateStyle) {
		DateStyle oldDateStyle = getDateStyle(date);
		return StringToString(date, oldDateStyle, newDateStyle);
	}

	public static String StringToString(String date, String olddPattern, String newPattern) {
		return DateToString(StringToDate(date, olddPattern), newPattern);
	}

	public static String StringToString(String date, DateStyle olddDteStyle, String newParttern) {
		String dateString = null;
		if (olddDteStyle != null) {
			dateString = StringToString(date, olddDteStyle.getValue(), newParttern);
		}

		return dateString;
	}

	public static String StringToString(String date, String olddPattern, DateStyle newDateStyle) {
		String dateString = null;
		if (newDateStyle != null) {
			dateString = StringToString(date, olddPattern, newDateStyle.getValue());
		}

		return dateString;
	}

	public static String StringToString(String date, DateStyle olddDteStyle, DateStyle newDateStyle) {
		String dateString = null;
		if (olddDteStyle != null && newDateStyle != null) {
			dateString = StringToString(date, olddDteStyle.getValue(), newDateStyle.getValue());
		}

		return dateString;
	}

	/**
	 * addYear
	 *
	 * @param date
	 * @param yearAmount
	 * @return
	 */
	public static String addYear(String date, int yearAmount) {
		return addInteger(date, 1, yearAmount);
	}

	public static Date addYear(Date date, int yearAmount) {
		return addInteger(date, 1, yearAmount);
	}

	public static String addMonth(String date, int monthAmount) {
		return addInteger(date, 2, monthAmount);
	}

	/**
	 * addMonth
	 *
	 * @param date        时间
	 * @param monthAmount
	 * @return
	 */
	public static Date addMonth(Date date, int monthAmount) {
		return addInteger(date, 2, monthAmount);
	}

	/**
	 * addDay
	 *
	 * @param date
	 * @param dayAmount
	 * @return
	 */
	public static String addDay(String date, int dayAmount) {
		return addInteger(date, 5, dayAmount);
	}

	public static Date addDay(Date date, int dayAmount) {
		return addInteger(date, 5, dayAmount);
	}

	/**
	 * addHour
	 *
	 * @param date
	 * @param hourAmount
	 * @return
	 */
	public static String addHour(String date, int hourAmount) {
		return addInteger(date, 11, hourAmount);
	}

	public static Date addHour(Date date, int hourAmount) {
		return addInteger(date, 11, hourAmount);
	}

	/**
	 * addMinute
	 *
	 * @param date
	 * @param minuteAmount
	 * @return
	 */
	public static String addMinute(String date, int minuteAmount) {
		return addInteger(date, 12, minuteAmount);
	}

	public static Date addMinute(Date date, int minuteAmount) {
		return addInteger(date, 12, minuteAmount);
	}

	/**
	 * addSecond
	 *
	 * @param date
	 * @param secondAmount
	 * @return
	 */
	public static String addSecond(String date, int secondAmount) {
		return addInteger(date, 13, secondAmount);
	}

	public static Date addSecond(Date date, int secondAmount) {
		return addInteger(date, 13, secondAmount);
	}

	public static int getYear(String date) {
		return getYear(StringToDate(date));
	}

	public static int getYear(Date date) {
		return getInteger(date, 1);
	}

	public static int getMonth(String date) {
		return getMonth(StringToDate(date));
	}

	public static int getMonth(Date date) {
		return getInteger(date, 2) + 1;
	}

	public static int getDay(String date) {
		return getDay(StringToDate(date));
	}

	public static int getDay(Date date) {
		return getInteger(date, 5);
	}

	public static int getHour(String date) {
		return getHour(StringToDate(date));
	}

	public static int getHour(Date date) {
		return getInteger(date, 11);
	}

	public static int getMinute(String date) {
		return getMinute(StringToDate(date));
	}

	public static int getMinute(Date date) {
		return getInteger(date, 12);
	}

	public static int getSecond(String date) {
		return getSecond(StringToDate(date));
	}

	public static int getSecond(Date date) {
		return getInteger(date, 13);
	}

	public static String getDate(String date) {
		return StringToString(date, DateStyle.YYYY_MM_DD);
	}

	/**
	 * 获取年月日 str
	 *
	 * @param date
	 * @return
	 */
	public static String getDate(Date date) {
		return DateToString(date, DateStyle.YYYY_MM_DD);
	}

	/**
	 * 获取年月日 时分秒 str
	 *
	 * @param date
	 * @return
	 */
	public static String getDateTimeToString(Date date) {
		return DateToString(date, DateStyle.YYYY_MM_DD_HH_MM_SS);
	}

	public static String getDateTimeMsToString(Date date) {
		return DateToString(date, DateStyle.YYYY_MM_DD_HH_MM_SS_SSS);
	}

	public static String getTime(String date) {
		return StringToString(date, DateStyle.HH_MM_SS);
	}

	public static String getTime(Date date) {
		return DateToString(date, DateStyle.HH_MM_SS);
	}

	public static WeekEnum getWeek(String date) {
		WeekEnum week = null;
		DateStyle dateStyle = getDateStyle(date);
		if (dateStyle != null) {
			Date myDate = StringToDate(date, dateStyle);
			week = getWeek(myDate);
		}

		return week;
	}

	/**
	 * 根据日期获取时间是周几
	 *
	 * @param date
	 * @return
	 */
	public static WeekEnum getWeek(Date date) {
		WeekEnum week = null;
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		int weekNumber = calendar.get(7) - 1;
		switch (weekNumber) {
			case 0:
				week = WeekEnum.SUNDAY;
				break;
			case 1:
				week = WeekEnum.MONDAY;
				break;
			case 2:
				week = WeekEnum.TUESDAY;
				break;
			case 3:
				week = WeekEnum.WEDNESDAY;
				break;
			case 4:
				week = WeekEnum.THURSDAY;
				break;
			case 5:
				week = WeekEnum.FRIDAY;
				break;
			case 6:
				week = WeekEnum.SATURDAY;
		}

		return week;
	}

	public static int getIntervalDays(String date, String otherDate) {
		return getIntervalDays(StringToDate(date), StringToDate(otherDate));
	}


	/**
	 * 把秒转换为时分秒
	 *
	 * @param seconds 秒
	 * @return
	 */
	public static String formatSecond2HourMinSecond(Integer seconds) {
		if (seconds == null || seconds < 0) {
			return null;
		}
		int s = seconds;// 秒
		int m = 0;// 分
		int h = 0;// 小时
		if (seconds >= 60) {
			m = seconds / 60;
			s = s % 60;
			if (m >= 60) {
				h = m / 60;
				m = m % 60;
			}
		}
		String result = StringUtils.EMPTY;
		if (s > 0) {
			result = s + "秒";
		}
		if (m > 0) {
			result = m + "分" + result;
		}
		if (h > 0) {
			result = h + "小时" + result;
		}
		return result;
	}


	public static int getIntervalDays(Date date, Date otherDate) {
		int num = -1;
		Date dateTmp = StringToDate(getDate(date), DateStyle.YYYY_MM_DD);
		Date otherDateTmp = StringToDate(getDate(otherDate), DateStyle.YYYY_MM_DD);
		if (dateTmp != null && otherDateTmp != null) {
			long time = Math.abs(dateTmp.getTime() - otherDateTmp.getTime());
			num = (int) (time / 86400000L);
		}

		return num;
	}

	public static String getLnow(long time) {
		Calendar cal = Calendar.getInstance();
		long timel = cal.getTimeInMillis() - time;
		return timel / 1000L < 60L ? "1分钟以内" : (timel / 1000L / 60L < 60L ? timel / 1000L / 60L + "分钟前" : (timel / 1000L / 60L / 60L < 24L ? timel / 1000L / 60L / 60L + "小时前" : timel / 1000L / 60L / 60L / 24L + "天前"));
	}

	/**
	 * 获取时间差
	 *
	 * @param startTime 开始时间
	 * @param endTime   结束时间
	 * @param format    时间格式
	 * @return 返回相差字符串时间
	 */
	public static String dateDiff(String startTime, String endTime, String format) {
		SimpleDateFormat sd = new SimpleDateFormat(format);
		long nd = 86400000L;
		long nh = 3600000L;
		long nm = 60000L;
		long ns = 1000L;

		try {
			long diff = sd.parse(endTime).getTime() - sd.parse(startTime).getTime();
			long day = diff / nd;
			long hour = diff % nd / nh;
			long min = diff % nd % nh / nm;
			long sec = diff % nd % nh % nm / ns;
			return day + "天" + hour + "时" + min + "分" + sec + "秒";
		} catch (ParseException var22) {
			return null;
		}
	}

	/**
	 * 获取时间差
	 *
	 * @param startTime 开始时间
	 * @param endTime   结束时间
	 * @return
	 */
	public static String dateDiff(Date startTime, Date endTime) {
		long nd = 86400000L;
		long nh = 3600000L;
		long nm = 60000L;
		long ns = 1000L;
		long diff = endTime.getTime() - startTime.getTime();
		long day = diff / nd;
		long hour = diff % nd / nh;
		long min = diff % nd % nh / nm;
		long sec = diff % nd % nh % nm / ns;
		return day + "天" + hour + "时" + min + "分" + sec + "秒";
	}

	/**
	 * 将时间转化为 天-时-分-秒
	 *
	 * @param diff
	 * @return
	 */
	public static String dateDiffWithDay(long diff) {
		long nd = 86400000L;
		long nh = 3600000L;
		long nm = 60000L;
		long ns = 1000L;
		long day = diff / nd;
		long hour = diff % nd / nh;
		long min = diff % nd % nh / nm;
		long sec = diff % nd % nh % nm / ns;
		return day + "天" + hour + "时" + min + "分" + sec + "秒";
	}

	/**
	 * 将时间转化为 时-分-秒
	 *
	 * @param diff
	 * @return
	 */
	public static String dateDiff(long diff) {
		long nh = 3600000L;
		long nm = 60000L;
		long ns = 1000L;
		long hour = diff / nh;
		long min = diff % nh / nm;
		long sec = diff % nh % nm / ns;
		return hour + "时" + min + "分" + sec + "秒";
	}

	public static int dateDiffSeconds(Date startTime, Date endTime) {
		return (int) (endTime.getTime() - startTime.getTime()) / 1000;
	}

	public static int dateDiffMinutes(Date startTime, Date endTime) {
		return (int) (endTime.getTime() - startTime.getTime()) / 60000;
	}

	public static int dateDiffHours(Date startTime, Date endTime) {
		return (int) (endTime.getTime() - startTime.getTime()) / 3600000;
	}

	public static int dateDiffDays(Date startTime, Date endTime) {
		return (int) ((endTime.getTime() - startTime.getTime()) / 86400000);
	}

	public static Date long2date(String dateFormat, long millSec) {
		Date date = new Date(millSec);
		return date;
	}

	public static String date2isoDate(Date date) {
		long time = date.getTime();
		return long2isoDate(time);
	}

	public static String long2isoDate(long millSec) {
		return String.format("/Date(%s+0800)/", Long.valueOf(millSec));
	}

	/**
	 * 获取当前年月的第一天,保留时分秒
	 *
	 * @return
	 */
	public static Date monthFirstDayDate() {
		Calendar calendar = Calendar.getInstance();
		calendar.set(Calendar.DAY_OF_MONTH, 1);
		calendar.set(Calendar.HOUR_OF_DAY, 0);
		calendar.set(Calendar.MINUTE, 0);
		calendar.set(Calendar.SECOND, 0);
		return calendar.getTime();
	}

	/**
	 * 获取amount月amountDay日，保留时分秒
	 *
	 * @return
	 */
	public static Date oneMonthOneDayDate(int amount, int amountDay) {
		Calendar calendar = Calendar.getInstance();
		calendar.set(Calendar.MONTH, amount);
		calendar.set(Calendar.DAY_OF_MONTH, amountDay);
		calendar.set(Calendar.HOUR_OF_DAY, 0);
		calendar.set(Calendar.MINUTE, 0);
		calendar.set(Calendar.SECOND, 0);
		return calendar.getTime();
	}

	/**
	 * 获取前amount个月的amountDay天，保留时分秒
	 *
	 * @return
	 */
	public static Date preMonthAmountDayDate(int amount, int amountDay) {
		Calendar calendar = Calendar.getInstance();
		calendar.add(Calendar.MONTH, amount);
		calendar.add(Calendar.DAY_OF_MONTH, amountDay);
		calendar.set(Calendar.HOUR_OF_DAY, 23);
		calendar.set(Calendar.MINUTE, 59);
		calendar.set(Calendar.SECOND, 59);
		return calendar.getTime();
	}

	/**
	 * 获取传入时间的最大时分秒（23点59分59秒）
	 *
	 * @return
	 */
	public static Date getMaxDateTime(Date date) {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.set(Calendar.HOUR_OF_DAY, 23);
		calendar.set(Calendar.MINUTE, 59);
		calendar.set(Calendar.SECOND, 59);
		return calendar.getTime();
	}

	public static Date getMinDateTime(Date date) {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.set(Calendar.HOUR_OF_DAY, 0);
		calendar.set(Calendar.MINUTE, 00);
		calendar.set(Calendar.SECOND, 00);
		return calendar.getTime();
	}


	/**
	 * 获取某天某个时间整点
	 *
	 * @return
	 */
	public static Date getIntegralDate(Date date, int hour) {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.set(Calendar.HOUR_OF_DAY, hour);
		calendar.set(Calendar.MINUTE, 0);
		calendar.set(Calendar.SECOND, 0);
		calendar.set(Calendar.MILLISECOND, 0);
		return calendar.getTime();
	}


	/**
	 * 将时间转换为时间戳
	 */
	public static String dateToStamp(String s) throws ParseException {
		String res;
		SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Date date = simpleDateFormat.parse(s);
		long ts = date.getTime();
		res = String.valueOf(ts);
		return res;
	}

	/**
	 * 将时间戳转换为时间
	 */
	public static String stampToDate(String s) {
		String res;
		SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		long lt = new Long(s);
		Date date = new Date(lt);
		res = simpleDateFormat.format(date);
		return res;
	}

	/**
	 * 获取昨天0点
	 *
	 * @return
	 */
//    public static Date getYesterdayZero() {
//        Calendar calendar = Calendar.getInstance();
//        calendar.setTime(DateUtils.addDays(new Date(), -1));
//        calendar.set(Calendar.HOUR, 0);
//        calendar.set(Calendar.MINUTE, 0);
//        calendar.set(Calendar.SECOND, 0);
//        return calendar.getTime();
//    }


	//获取当天零点时间
//    public Date nowTime(){
//        Calendar calendar = Calendar.getInstance();
//        calendar.setTime(new Date());
//        calendar.set(Calendar.HOUR_OF_DAY, 0);
//        calendar.set(Calendar.MINUTE, 0);
//        calendar.set(Calendar.SECOND, 0);
//        calendar.set(Calendar.MILLISECOND,0);
//
//        Date zero = calendar.getTime();
//        return zero;
//    }

	/**
	 * @return java.util.Date
	 * @Description 当天时间，只保留年月日
	 * @date 2018-7-30 20:06
	 */
	public static Date getDayDate(Date date) {
		return DateTimeUtils.StringToDate(DateTimeUtils.getDate(date));
	}

	/**
	 * @Description 判断时间是否为null或者为1900-01-01
	 * @date 2018-12-20 14:22
	 */
	public static boolean isNullOrDefault(Date date) {
		return date == null || date.equals(BaseConstant.DEFAULT_DATE);
	}

}
